package com.xuexi.export;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class ConnectionUtil {

    private static final String DB_URL = "jdbc:mysql://localhost:3306/lzzg_design";
    private static final String USER = "root";
    private static final String PASSWORD = "passwd#123";
    private static final String OUTPUT_FILE = "exported_data.csv";

    public static final Connection connection;

    static {
        try {
            System.out.println("init connection start....");
            connection = DriverManager.getConnection(DB_URL, USER, PASSWORD);
            System.out.println("init connection success.");
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

    /*public static PreparedStatement getPreparedStatement(String querySql) throws SQLException {
        return connection.prepareStatement(querySql);
    }*/

    public static void close() throws SQLException {
        if (connection != null) {
            connection.close();
        }
    }
}
